package com.multithreading.algorithm;

/**
 * @author zx
 * @version 1.0
 * @package_name: com.multithreading.algorithm
 * @date 2024/6/19 18:11
 */
// 扩容
public class Array_test006 {
    public static void main(String[] args) {
        int[] arr = new int[]{1, 2, 3, 4, 5};
        // 现在将数组扩容 1 倍
        int[] newArr = new int[arr.length * 2];
        // int[] arr1 = new int[arr.length << 1];
        System.arraycopy(arr, 0, newArr, 0, arr.length);

        newArr[arr.length] = 10;
        newArr[arr.length + 1] = 20;
        newArr[arr.length + 2] = 30;

        arr = newArr;

        for (int oldArr : arr) {
            System.out.print(oldArr + " ");
        }
    }
}
